import { Model } from 'pinia-orm';
import { Attr, Str, Uid, Num, Bool, HasOne, HasMany, BelongsTo, HasManyBy, BelongsToMany, MorphOne,
  MorphTo, MorphMany, MorphToMany, OnDelete
  } from 'pinia-orm/decorators';
import { useAxiosRepo } from '@pinia-orm/axios';
import { useAppConfig } from '@vben/hooks';
import type { MinishopOrder, MinishopOrderResponse } from '../../views/uctoo/minishop_order/types.js';
//#region Human-Code Preservation

//#endregion Human-Code Preservation

const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);

export class uctoo_minishop_order extends Model {
  static override entity = 'uctoo_minishop_order'

@Uid() declare id: string 
@Str('') declare order_id: string | null
@Str('') declare out_order_id: string 
@Str('') declare out_trade_no: string | null
@Str('') declare openid: string 
@Str('') declare user_id: string | null
@Num(0) declare type: number 
@Str('') declare path: string | null
@Num(0) declare scene: number | null
@Str('') declare order_detail_id: string | null
@Str('') declare address_info_id: string | null
@Str('') declare out_aftersale_id: string | null
@Str('') declare ticket: string | null
@Attr('') declare ticket_expire_time: string | null
@Num(0) declare final_price: number | null
@Str('') declare ext_json: string | null
@Str('') declare platform: string 
@Str('') declare transaction_id: string | null
@Uid() declare creator: string | null
@Attr('') declare created_at: string 
@Attr('') declare updated_at: string 
@Attr('') declare deleted_at: string | null
@Num(0) declare status: number 
@Str('') declare appid: string | null


  static override config = {
    axiosApi: {
        actions: {
            getuctooMinishopOrderList(page: number, pageSize: number, searchParams?: any){
                return useAxiosRepo(uctoo_minishop_order).api().get(`/uctoo/minishop_order/${pageSize}/${page}`, {
                  params: searchParams,
                  headers: { 'Content-Type': 'application/json;charset=utf-8',
                          'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                  },
                  baseURL: apiURL,
                  dataKey: 'minishopOrders'
                })
            },
            getuctooMinishopOrder(id: string){
              return useAxiosRepo(uctoo_minishop_order).api().get(`/uctoo/minishop_order/${id}`, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            adductooMinishopOrder(data: Partial<MinishopOrder>){
              return useAxiosRepo(uctoo_minishop_order).api().post('/uctoo/minishop_order/add', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            edituctooMinishopOrder(data: any){
              return useAxiosRepo(uctoo_minishop_order).api().post('/uctoo/minishop_order/edit', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            deleteuctooMinishopOrder(data: any){
              return useAxiosRepo(uctoo_minishop_order).api().post('/uctoo/minishop_order/del', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },

//#region Human-Code Preservation
createUserOrder(data: Partial<MinishopOrder>){ //
              return useAxiosRepo(uctoo_minishop_order).api().post('/uctoo/minishop_order/createUserOrder', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL
              })
            },
            handleOrderFinalPrice(data: Partial<MinishopOrder>){
              return useAxiosRepo(uctoo_minishop_order).api().post('/uctoo/minishop_order/handleOrderFinalPrice', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL
              })
            },
//#endregion Human-Code Preservation
        } 
    }
  }
}
